package com.heima.controller;

import com.heima.pojo.dto.DeviceQueryDTO;
import com.heima.pojo.dto.NodeVmDTO;
import com.heima.pojo.dto.PartnerQueryDTO;
import com.heima.pojo.entity.VmType;
import com.heima.pojo.vo.SkuClassPageVO;
import com.heima.pojo.vo.VendingMachineVO;
import com.heima.service.VmTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/vm-service")
public class VmTypeController {
    @Autowired
    private VmTypeService vmTypeService;


    @GetMapping("/vmType/search")
    public SkuClassPageVO<VmType> search( PartnerQueryDTO dto){
        SkuClassPageVO<VmType> vm=vmTypeService.queryPage(dto);
        return vm;
    }
    @PostMapping("/vmType")
    public Boolean add( @RequestBody  VmType vmType){
        vmTypeService.add(vmType);
        return true;
    }
    @PutMapping("/vmType/{typeId}")
    public Boolean update(@PathVariable Integer typeId,@RequestBody VmType vmType){
        return vmTypeService.update(typeId,vmType);
    }
    @DeleteMapping("/vmType/{typeId}")
    public Boolean detele(@PathVariable Integer typeId){
        return  vmTypeService.detele(typeId);
    }

    @GetMapping("/vm/search")
    public SkuClassPageVO<VendingMachineVO> searchAll( DeviceQueryDTO deviceQueryDTO){
        return vmTypeService.searchAll(deviceQueryDTO);
    }
    @PostMapping("/vm")
    public Boolean addVm(@RequestBody NodeVmDTO nodeVmDTO){
      return  vmTypeService.addVm(nodeVmDTO);
    }
}
